import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        while (t > 0) {
            t--;
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
            }
            String str = sc.next();

            int count = 0;
            int[] temp = new int[n];

            for (int i = 0; i < n; i++) {
                if (str.charAt(i) == '>') {
                    temp[i] = 1;
                } else if (str.charAt(i) == '<') {
                    temp[i] = -1;
                } else {
                    temp[i] = temp[i - 1];
                }
                if (temp[i] * arr[i] <= 0) {
                    count++;
                }
            }

            System.out.println(count);
        }

        sc.close();
    }
}